I want to loop through all baselines of a module to gather some stats, so I'm using: |
Re: How to load the 'current' version of a module
I usually use this pattern:
Module mod = current
Skip sk = create()
Baseline B = null
// put the current Module in there with a NULL baseline
put (sk, 99999, B)
int i = 0
// put the baselines in the skip before the current Module
for B in current Module do { put (sk, i++, B) }
// iterate through the baselines + the current Module
for B in sk do {
Module m
if (null B) m = mod else m = load(mod , B, false)
if (null m) {
print "Could not load baseline " (versionString moduleVersion (fullName current,B)) "\n"
continue
}
// do something with the module m
print "Processing " (name m) " " (versionString moduleVersion m) "\n"
// maybe close the baseline when you are finished?
if (!null B) close m
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: How to load the 'current' version of a module Mathias Mamsch - Thu May 27 08:18:36 EDT 2010
I usually use this pattern:
Module mod = current
Skip sk = create()
Baseline B = null
// put the current Module in there with a NULL baseline
put (sk, 99999, B)
int i = 0
// put the baselines in the skip before the current Module
for B in current Module do { put (sk, i++, B) }
// iterate through the baselines + the current Module
for B in sk do {
Module m
if (null B) m = mod else m = load(mod , B, false)
if (null m) {
print "Could not load baseline " (versionString moduleVersion (fullName current,B)) "\n"
continue
}
// do something with the module m
print "Processing " (name m) " " (versionString moduleVersion m) "\n"
// maybe close the baseline when you are finished?
if (!null B) close m
}
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
But one other problem I'm now finding: I need to load a specific view (because of its filter, for counting). So I've in the loop included: load (view viewname) (this is after load of baseline has already occured). However this isn't doing the trick. I think it may be because it is loading the view on that initial module (mod) rather than the one I'm using in the loop (m), but I'm not sure. Any ideas? |
Re: How to load the 'current' version of a module kierant - Fri May 28 05:16:48 EDT 2010 load (m, view "Name"). Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: How to load the 'current' version of a module kierant - Fri May 28 05:16:48 EDT 2010
:title=kierant wrote:}
> I guess the key is that you've used a separate handle (m) rather than the initial one (mod current) so that you can load it (current) or a specific baseline of it.It should be routine for scripts that care what module invoked them to have some sort of "Module mCurr = current()" at the top of the code, and not modified anywhere. Rarely use 'current Module' elsewhere in the code since the 'current' module can and does change when other modules are open, in a pattern that's hard to predict. Later, when you really care you can issue "current = mCurr" to set it back; perhaps to load a view.
|